package com.yonyou.gulimall.ware.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.yonyou.common.to.SkuHasStockVo;
import com.yonyou.common.utils.PageUtils;
import com.yonyou.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.gulimall.ware.entity.WmsWareSkuEntity;
import com.yonyou.gulimall.ware.service.WmsWareSkuService;



/**
 * 商品库存
 *
 * @author sunzhongshun
 * @email zhongshun_sun@126.com
 * @date 2021-10-11 14:30:38
 */
@RestController
@RequestMapping("ware/waresku")
public class WmsWareSkuController {

    @Autowired
    private WmsWareSkuService wmsWareSkuService;

    /**
     * 查询sku是否有库存
     * @param ids
     * @return
     */
    @RequestMapping("/getSkuHasStocks")
    public List<SkuHasStockVo> getSkuHasStocks(@RequestBody List<Long> ids) {
        return wmsWareSkuService.getSkuHasStocks(ids);
    }
    /********************************************/
    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("ware:wmswaresku:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = wmsWareSkuService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
   // @RequiresPermissions("ware:wmswaresku:info")
    public R info(@PathVariable("id") Long id){
		WmsWareSkuEntity wmsWareSku = wmsWareSkuService.getById(id);

        return R.ok().put("wmsWareSku", wmsWareSku);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ware:wmswaresku:save")
    public R save(@RequestBody WmsWareSkuEntity wmsWareSku){
		wmsWareSkuService.save(wmsWareSku);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("ware:wmswaresku:update")
    public R update(@RequestBody WmsWareSkuEntity wmsWareSku){
		wmsWareSkuService.updateById(wmsWareSku);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
  //  @RequiresPermissions("ware:wmswaresku:delete")
    public R delete(@RequestBody Long[] ids){
		wmsWareSkuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
